<?php
/*
 * File "head.php"
 *
 * Created on 20/mar/09
 * @author gabrielepiva
 * @email www.gabri@gmail.com
 *
 * @projectName newcomer-theme1
 * @workgroup Nerd Riot
 *
 * @param title: titolo della pagina
 * \brief Contiene la header della pagina
 *
 *
 *
 */
require_once("config.php");
require_once SESSION_INCLUDE;
require_once DB;

	$db = get_session_db($db_config);

	if(!user_is_logged($db))
	{
		header("Location:http://".LOGIN_FILE);
		exit();
	}

	$user = get_session_user();
?>
<head>
	<meta http-equiv="Content-Language" content="en" />
	<meta name="GENERATOR" content="PHPEclipse 1.0" />
	<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
	<title><?php if(isset($_GET['title'])) echo $_GET['title']; else echo SITE_NAME." - Administration ".THEME_VERSION; ?></title>

	<link rel="stylesheet" type="text/css" href="theme1.css" />
	<link rel="stylesheet" type="text/css" href="gallery.v2.css" />
	<link rel="stylesheet" type="text/css" href="events.css" />
	<link rel="stylesheet" type="text/css" href="lib/facebox.css" />


	<script src="lib/jquery-1.3.2.js" type="text/javascript"></script>
	<script src="lib/jquery-ui-1.7.1.custom.min.js" type="text/javascript"></script>
	<script src="lib/jquery.form.js" type="text/javascript"></script>
	<script src="lib/JSON.js" type="text/javascript" ></script>
	<script src="lib/gallery.v2.js" type="text/javascript" ></script>
	<script src="lib/events.js" type="text/javascript" ></script>
	<script src="lib/jquery.aqstamp.js" type="text/javascript"></script>
	<script src="lib/jquery.corners.js" type="text/javascript"></script>
	<script src="lib/jquery.facebox.js" type="text/javascript"></script>
	<script src="lib/jquery.history.js" type="text/javascript"></script>
	<script src="lib/jquery.jeditable.js" type="text/javascript"></script>
	<script src="lib/jquery.ajaxUpload.js" type="text/javascript"></script>
	<script src="lib/jquery.hotkeys.js" type="text/javascript" ></script>
	<script src="functions.js" type="text/javascript"></script>

	<script type="text/javascript" src="domready.js"></script>
	<script type="text/javascript" >
		user_id = <?php echo $user->getId(); ?>;

		$.editable.addInputType('datepicker', {
        element: function(settings, original) {
                var dayselect = $('<select id="day_">');
                var monthselect = $('<select id="month_">');
                var yearselect = $('<select id="year_">');

                for(var day=1; day <=31; day++) {
                        if(day < 10) {
                                day = '0' + day;
                        }
                        var option = $('<option>').val(day).append(day);
                        dayselect.append(option);
                }
                $(this).append(dayselect);

                for(var month=1; month <= 12; month++) {
                        var monthname = [];
                        monthname[1] = "January";
                        monthname[2] = "February";
                        monthname[3] = "March";
                        monthname[4] = "April";
                        monthname[5] = "May";
                        monthname[6] = "June";
                        monthname[7] = "July";
                        monthname[8] = "August";
                        monthname[9] = "September";
                        monthname[10] = "October";
                        monthname[11] = "November";
                        monthname[12] = "December";
                        if(month < 10) {
                                monthnum = '0' + month;
                        } else {
                                monthnum = month;
                        }
                        var option = $('<option>').val(monthname[month]).append(monthname[month]);
                        monthselect.append(option);
                }
                $(this).append(monthselect);

                for(var year=<?php echo date('Y'); ?>; year >= <?php echo date('Y')-70; ?>; year--) {
                        var option = $('<option>').val(year).append(year);
                        yearselect.append(option);
                }
                $(this).append(yearselect);

                var hidden = $('<input type="hidden">');
                $(this).append(hidden);
                return(hidden);
        },
        content: function(string, settings, original) {
                var day = parseInt(string.substr(0,2));
                var month = parseInt(string.substr(3,2));
                var year = parseInt(string.substr(6,4));

                $("#day_", this).children().each(function() {
                        if(day == $(this).val()) {
                                $(this).attr('selected', 'selected');
                        }
                });

                $("#month_", this).children().each(function() {
                        if(month == $(this).val()) {
                                $(this).attr('selected', 'selected');
                        }
                });

                $("#year_", this).children().each(function() {
                        if(year == $(this).val()) {
                                $(this).attr('selected', 'selected');
                        }
                });
        },
        submit: function(settings, original) {
                var value= $("#day_").val() + " " + $("#month_").val() + " " + $("#year_").val();
                $("input", this).val(value);
        }

});
	</script>

</head>
